

//
//  MyMessageContentVC.m
//  BusinessMarket
//
//  Created by Michael Li on 2018/11/1.
//  Copyright © 2018年 Michael Li. All rights reserved.
//

#import "MyMessageContentVC.h"
#import "MessageModel.h"
#import "ImageViewCell.h"
#import "WriteRequirementTitleCell.h"
#import "MyMessageContentCell.h"
#import "UIImage+ImgSize.h"
#import "XHWebImageAutoSize.h"
@interface MyMessageContentVC ()
@property(nonatomic,assign) NSInteger imageHeight;
@end
static NSString *identifierTitle = @"TitleCell";
static NSString *identifierRed = @"redCell";
@implementation MyMessageContentVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = self.msgModel.title;
    [self.tableView registerNib:[UINib nibWithNibName:@"WriteRequirementTitleCell" bundle:nil] forCellReuseIdentifier:identifierTitle];
    [self.tableView registerNib:[UINib nibWithNibName:@"MyMessageContentCell" bundle:nil] forCellReuseIdentifier:identifierRed];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    if (indexPath.row == 0) {
        ImageViewCell *cell = [ImageViewCell cellNibWithTableView:tableView];
        cell.msgModel = self.msgModel;
        return cell;
    }else  if (indexPath.row == 1) {
        WriteRequirementTitleCell *cell = [tableView dequeueReusableCellWithIdentifier:identifierTitle forIndexPath:indexPath];
        cell.msgModel = self.msgModel;
        return cell;
    }else {
        MyMessageContentCell *cell = [tableView dequeueReusableCellWithIdentifier:identifierRed forIndexPath:indexPath];
        cell.msgModel = self.msgModel;
        return cell;
    }
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
//        CGSize size = [UIImage getImageSizeWithURL:[NSURL URLWithString:self.msgModel.icon]];
//        XLog(@"size:%f",size.height);
        return [XHWebImageAutoSize imageWidthForURL:[NSURL URLWithString:self.msgModel.icon] layoutHeight:50 estimateWidth:kVWidth-32];
//        return size.height*(kVWidth-18*2)/size.width;
    }else if (indexPath.row == 1) {
        CGFloat cellHeight = [MCLabel getHeightWithTitle:self.msgModel.content withFontSize:12]+80;
        return cellHeight;
    }else {
        return 20;
    }
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 10)];
    return headerView;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 0,1)];
    return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.1;
}
@end
